<?php 
require 'emp.php';

$search=(isset($_GET['search']))?$_GET['search']:"";
$sql="select * from tb_emp where e_dept like '%{$search}%' or e_name like '%{$search}%'";
$result=$db->query($sql);
$sum=$result->num_rows;

$hu=5;
$pg=  isset($_GET['pg'])?$_GET['pg']:1;
$gg=$result->num_rows;
$wei=  ceil($gg/$hu);
$pg=($pg<=0)?1:$pg;
$pg=($pg>$wei)?$wei:$pg;
$qei=($pg-1)*$hu;
$sql="select * from tb_emp where e_dept like '%{$search}%' or e_name like '%{$search}%'   limit {$qei},{$hu}";

//$sql="select * from tb_emp ";
$result=$db->query($sql);

$rows=$result->fetch_all(MYSQLI_ASSOC);

   session_start();
   if (isset($_SESSION['userinfo']))
   {
       $login=true;
       $userinfo=$_SESSION['userinfo'];
   }
    else {
    echo "<script language='javascript'>";
    echo "alert('您还没登录，请先登录！');";
    echo "window.location.href='login.php';";
    echo "</script>";
    die;
   }

 include 'list_html.php';
$db->close();